package com.lkbaby.task;

import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component;

import java.io.Serializable;

@Component(value = "mulitiInstanceCompleteTask")
public class MulitiInstanceCompleteTask implements Serializable {

	/**
	 * 完成任务是需要触发的方法
	 *
	 * @param execution
	 * @return 当会前任务全部同意时
	 */
	public boolean completeTask(DelegateExecution execution) {
		System.out.println("总的会签任务数量：" + execution.getVariable("nrOfInstances")
				+ "\n当前获取的会签任务数量：" + execution.getVariable("nrOfActiveInstances")
				+ "\n已经完成的会签任务数量：" + execution.getVariable("nrOfCompletedInstances"));
		Boolean status =  execution.getVariable("agree").equals(execution.getVariable("nrOfInstances"));
		if (execution.getVariable("nrOfInstances") == execution.getVariable("nrOfCompletedInstances") && status == false){
			status = true;
		}
		return status;
	}
}
